package com.raising.sc.log.client.service;

import com.alibaba.fastjson.JSON;
import com.raising.sc.log.client.config.RabbitClientConfig;
import com.raising.sc.log.client.entity.ApiLog;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 日志服务层
 * 保存日志或者存储至消息中间件
 * @author GaoYuan
 * @date 2018/4/9 下午3:48
 */
@Service
public class ApiLogClientService {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void log(ApiLog sysLog){
        rabbitTemplate.convertAndSend(RabbitClientConfig.queueName, JSON.toJSONString(sysLog));
    }
}
